package com.micro.service.service;

import com.micro.service.model.UserArticle;
import com.micro.service.mongoDao.UserArticleMongoDao;
import com.micro.service.mongoDao.UserArticleRepository;
import com.mongodb.client.result.DeleteResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Create by Vic Xu on 2019/3/9
 */
@Service
public class UserArticleServiceImpl implements UserArticleService {

    @Autowired
    private UserArticleRepository userArticleRepository;

    @Override
    public UserArticle saveUserArticle(UserArticle userArticle) {
        return userArticleRepository.save(userArticle);
    }

    @Override
    public List<UserArticle> findAll() {
        return userArticleRepository.findAll();
    }

    @Override
    public List<UserArticle> findByCardId(UserArticle userArticle) {
        return userArticleRepository.findUserArticleByCardId(userArticle.getCardId());
    }

    @Override
    public UserArticle updateUserArticle(UserArticle userArticle) {
        return userArticleRepository.save(userArticle);
    }

    @Override
    public void deleteUserArticleById(Object id) {
        userArticleRepository.deleteById((String) id);
    }
}
